package cn.demoxy.utils;

import java.lang.reflect.Method;

/**
 * @auther demo
 * @date 2022/8/29 9:03
 * 反射工具类
 */
public class ReflectUtils {
    /**
     * 获取结果
     *
     * @param key
     * @return
     */
    public String getResult(String key) {
        System.out.println("Key: " + key);
        return key;
    }

    /**
     * 获取代理类
     *
     * @param className
     * @return
     * @throws ClassNotFoundException
     */
    public Class getProxyClass(String className) throws ClassNotFoundException {
        Class clazz = Class.forName(className);

        return clazz;
    }

    /**
     * 获取代理方法
     *
     * @param methodName
     * @param clazz
     * @return
     * @throws NoSuchMethodException
     */
    public Method getProxyMethod(String methodName, Class clazz) throws NoSuchMethodException {
        Method method = clazz.getMethod(methodName, String.class);
        return method;
    }
}
